package com.tian.controller;

import com.tian.annotation.LoginCheckAnnotation;
import com.tian.dto.req.RoleAddReqDto;
import com.tian.dto.resp.PageDto;
import com.tian.dto.resp.RoleRespDto;
import com.tian.service.RoleService;
import com.tian.utils.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * {@code @description:} TODO
 *
 * @author tianwc 公众号：Java后端技术全栈
 * 在线刷题 1200+java面试题和1000+篇技术文章：<a href="https://woaijava.cc/">博客地址</a>
 * {@code @date:} 2024-09-10 8:42
 * {@code @version:} 1.0
 */
@RestController
@RequestMapping("/management/role")
public class RoleController {
    @Resource
    private RoleService roleService;

    @LoginCheckAnnotation
    @GetMapping("/list")
    public Result<PageDto<List<RoleRespDto>>> list() {
        return roleService.allRole();
    }

    @LoginCheckAnnotation
    @GetMapping("/delete/{id}")
    public Result delete(@PathVariable("id") Integer id) {
        return roleService.deleteRole(id);
    }

    @LoginCheckAnnotation
    @PostMapping("/add")
    public Result add(@RequestBody RoleAddReqDto roleAddReqDto) {
        return roleService.addRole(roleAddReqDto);
    }
}
